package app.file;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

import app.controller.ChequeController;

public class FileManager {
	
	private final static String CONTROLLER_FILE = "cheques.cf";
	
	public static void salvarArquivo(ChequeController cc) throws FileNotFoundException, IOException {
		
		ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(CONTROLLER_FILE));
		
		oos.writeObject(cc);
		
		oos.close();
	}
	
	public static ChequeController carregarArquivo() throws IOException, ClassNotFoundException {
		
		ObjectInputStream ois = new ObjectInputStream(new FileInputStream(CONTROLLER_FILE));
		
		ChequeController cc = (ChequeController) ois.readObject();
		
		ois.close();
		
		return cc;
		
	}

}
